package com.windchimes.edueval_platform.domain.vo;

import com.windchimes.edueval_platform.domain.po.Student;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 学生视图对象
 */
@Data
public class StudentVO {

    /**
     * 学生ID
     */
    private Long id;

    /**
     * 学号
     */
    private String studentNumber;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 状态 0:禁用，1:正常
     */
    private Integer status;

    /**
     * 学院
     */
    private String institute;

    /**
     * 年级
     */
    private String grade;

    /**
     * 专业
     */
    private String major;

    /**
     * 班级
     */
    private String theClass;

    /**
     * 姓名
     */
    private String name;

    /**
     * 性别 0:女，1:男
     */
    private Integer sex;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 角色类型，默认"student"
     */
    private String roleType = "student";

    /**
     * 从Student实体转换为StudentVO
     */
    public static StudentVO fromStudent(Student student) {
        if (student == null) {
            return null;
        }

        StudentVO vo = new StudentVO();
        vo.setId(student.getId());
        vo.setStudentNumber(student.getStudentNumber());
        vo.setPhone(student.getPhone());
        vo.setStatus(student.getStatus());
        vo.setInstitute(student.getInstitute());
        vo.setGrade(student.getGrade());
        vo.setMajor(student.getMajor());
        vo.setTheClass(student.getTheClass());
        vo.setName(student.getName());
        vo.setSex(student.getSex());
        vo.setCreateTime(student.getCreateTime());
        vo.setUpdateTime(student.getUpdateTime());
        return vo;
    }
}